package top.kaoshanji.p2ch06a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.u1constant.FileConstant;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;

/**
 * 代码清单 p2ch06a-09：进程的输入和输出的文件式处理方式的示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/17 18:29
 */
public class ProcessExample03 {

    private static final Logger logger = LogManager.getLogger(ProcessExample03.class);

    public static void main(String[] args) throws IOException {
        logger.info("...代码清单 p2ch06a-09：进程的输入和输出的文件式处理方式的示例...");

        ProcessBuilder pb = new ProcessBuilder("wmic", "process");
        File output = Paths.get(FileConstant.LOCAL_ROOT_PATH.concat("p2ch06a09-tasks.txt")).toFile();
        pb.redirectOutput(output);
        pb.start();

    }

}
